import 'package:ati_package/core/extension/ati_widgets_extension.dart';
import 'package:ati_package/core/routes/app_routes.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../core/utils/ati_assets.dart';
import '../../../core/utils/ati_color.dart';
import '../../../core/utils/ati_enum.dart';
import '../../../core/utils/ati_font.dart';
import '../other/widgets/invite_friends_view.dart';

class UserHWidget extends StatelessWidget {
  const UserHWidget({super.key});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: Get.width / 1.44,
      width: double.infinity,
      padding: EdgeInsets.symmetric(horizontal: 16.r),
      decoration: BoxDecoration(
        image: DecorationImage(
          image: AssetImage(AtiAssets.userHBg, package: 'ati_package'),
        ),
      ),
      child: SafeArea(
        child: Column(
          children: [
            Row(
              children: [
                CircleAvatar(
                  radius: 37.5.r,
                  backgroundColor: Colors.white,
                  child: CircleAvatar(
                    radius: 35.r,
                    backgroundImage: CachedNetworkImageProvider(
                      'https://picsum.photos/800/400?blur',
                    ),
                  ),
                ),
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      '初吻给了眼',
                      style: TextStyle(
                        color: AtiColor.textColor1,
                        fontSize: AtiFont.font14,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                    SizedBox(height: 5.r),
                    Text(
                      'UID：127774747',
                      style: TextStyle(
                        color: Color(0xFF666666),
                        fontSize: AtiFont.font12,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                    SizedBox(height: 7.5.r),
                    Text(
                      '这个人有点懒，还没有签名呢～～',
                      style: TextStyle(
                        color: Color(0xFF666666),
                        fontSize: AtiFont.font10,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                  ],
                ),
                Spacer(),
                Image.asset(
                  width: 20.r,
                  height: 20.r,
                  AtiAssets.userHCode,
                  package: 'ati_package',
                ).addTapGesture(
                  onTap: () {
                    Get.toNamed(AtiAppRoutes.userCode);
                  },
                ),
                SizedBox(width: 10.r),
                Image.asset(
                  width: 20.r,
                  height: 20.r,
                  AtiAssets.atiNextIcon,
                  package: 'ati_package',
                ),
              ],
            ).addTapGesture(
              onTap: () {
                Get.toNamed(AtiAppRoutes.userInfos);
              },
            ),
            SizedBox(height: 10.r),
            _buildHeaderListBtn(),
          ],
        ),
      ),
    );
  }

  _buildHeaderListBtn() {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: [
        _buildBtnItem(
          UserCenterModel.userCenterWallet,
          AtiAssets.userHwdqb,
          '我的钱包',
        ),
        _buildBtnItem(
          UserCenterModel.userCenterTrend,
          AtiAssets.userHwddt,
          '我的动态',
        ),
        _buildBtnItem(
          UserCenterModel.userCenterCollect,
          AtiAssets.userHwdsc,
          '我的收藏',
        ),
        _buildBtnItem(
          UserCenterModel.userCenterInviteFriends,
          AtiAssets.userHyqhy,
          '邀请好友',
        ),
      ],
    );
  }

  _buildBtnItem(
    UserCenterModel centerModel,
    String bgImageStr,
    String titleStr,
  ) {
    return Container(
      width: 65.r,
      height: 65.r,
      alignment: Alignment.bottomCenter,
      padding: EdgeInsets.only(bottom: 10.r),
      decoration: BoxDecoration(
        image: DecorationImage(
          image: AssetImage(bgImageStr, package: 'ati_package'),
        ),
      ),
      child: Text(
        titleStr,
        style: TextStyle(
          color: AtiColor.textHLColor1,
          fontSize: AtiFont.font12,
        ),
      ),
    ).addTapGesture(
      onTap: () {
        switch (centerModel) {
          case UserCenterModel.userCenterWallet:
            {
              Get.toNamed(AtiAppRoutes.userMyWallet);
            }
            break;
          case UserCenterModel.userCenterTrend:
            {
              Get.toNamed(AtiAppRoutes.userTrend);
            }
            break;

          case UserCenterModel.userCenterCollect:
            {
              Get.toNamed(AtiAppRoutes.userCollects);
            }
            break;

          case UserCenterModel.userCenterInviteFriends:
            {
              Get.dialog(InviteFriendsView());
            }
            break;

          default:
            {}
            break;
        }
      },
    );
  }
}
